package worldinruin.gui.imp.gameview;
import java.awt.GridLayout;

import javax.swing.JPanel;
import javax.swing.border.LineBorder;

import worldinruin.core.ISoldier;
import worldinruin.core.ITroop;

/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class BattleTroopPanel extends JPanel {
	
	ITroop troop;
	
	/**
	 * Creates a battle troop panel with the assigned troop.
	 * @param troop Troop displayed in panel.
	 */
	public BattleTroopPanel(ITroop troop) {
		this.troop = troop;
		setupGUI();
	}
	
	/**
	 * Setup GUI.
	 */
	private void setupGUI() {
		GridLayout thisLayout = new GridLayout(troop.getSoldiers().size(), 1);
		setBorder(new LineBorder(troop.getPlayer().getColor()));
		thisLayout.setColumns(1);
		thisLayout.setHgap(5);
		thisLayout.setVgap(5);
		this.setLayout(thisLayout);
		for (ISoldier s : troop.getSoldiers()) {
			BattleUnitComponent buc = new BattleUnitComponent(s, troop.getAmount(s));
			add(buc);
		}
	}

	

}
